var gLoginUsername = "${loginUsername}"; // 获得当前登录人员的userName
var gDeptUid = '${request.getParameter("deptUid")}';
var curDept;

// @Bind @dtDept.onDataChange
!function(self, arg) {
	var ds = view.id('dsDept');
	var cur = ds.getData('#');

	if (cur) {
		if (arg.property == "uuid") {
			cur.set("BDFDept.id", cur.get("uuid"));
		}
	}
}

// @Bind @dtDept.beforeInsert
!function(self, arg) {
	var newDept = arg.entity;
	newDept.set("parentDeptUid", curDept.get("uuid"));
	newDept.set("createTime", new Date());
	newDept.set("creatorUid", gLoginUsername);
	newDept.set("creator.employeeName", gLoginUsername);//...
}

//@Bind #actionSaveDept.onSuccess
!function(self,arg,dsDept) {
dsDept.flushAsync();

}

//@Bind #deptTree.onDataRowClick
!function(self, arg) {
	var curEntity = self.get("currentEntity");
	var dsDept = view.id("dsDept");

	if (curEntity.dataType.get("name") == "dtDept"){
		dsDept.set("parameter", {
			deptUid : curEntity.get("uuid")
		});
		
		curDept = curEntity;
	}
	
	dsDept.flush();
}

